package com.vincent.kdp.Activity;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.webkit.WebSettings;
import android.webkit.WebView;

import com.vincent.kdp.PostUrl;
import com.vincent.kdp.R;
import com.vincent.kdp.js.JsOperator;

public class WebViewActivity extends AppCompatActivity {
  
    private WebView webView;
  
    @Override  
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.activity_webview);
  
        this.webView = (WebView) this.findViewById(R.id.webView);  
        this.initializeWebView();  
    }  
      
    @SuppressLint({ "NewApi", "SetJavaScriptEnabled" })
    private void initializeWebView(){  
        webView.addJavascriptInterface(new JsOperator(WebViewActivity.this),
                "JsInteraction");  
        try {  
            //String url = "file:///android_asset/LoginJs/login.html";
            String url= PostUrl.SERVICE_URL+"/H5/opinionSurvey/opinionSurvey.html";
            WebSettings webSettings = webView.getSettings();
            webSettings.setJavaScriptEnabled(true);  
            webSettings.setAllowFileAccess(true);  
            webSettings.setAllowFileAccessFromFileURLs(true);  
  
            this.webView.loadUrl(url);  
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
    }
}